package org.iori.lxServlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class FileUploadStatus
 */
@WebServlet("/FileUploadStatus")
public class FileUploadStatus extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public FileUploadStatus() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = response.getWriter();
		HttpSession session = request.getSession();
		
		Object obj_progress_disabled = session.getAttribute("progress_disabled");
		if (null != obj_progress_disabled) {
			boolean progress_disabled = Boolean.parseBoolean(obj_progress_disabled.toString());
			if (false == progress_disabled) {
				session.removeAttribute("progress_num");
				return;
			}
		}
		
		Object obj_progress_num = session.getAttribute("progress_num");
		if (null != obj_progress_num) {
			int progress_num = Integer.valueOf(obj_progress_num.toString());//获取上传进度百分比
			System.out.println(progress_num + "% FileUploadStatus");
			out.println(progress_num);//响应
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		this.doGet(request, response);
	}

}
